<?php
$getReq = "";
if ($data['method'] == "POST") {
    $reqParams = "reqParams {$data['function_name']}Req";
    $function = "WithStruct(reqParams)";
    $getReq = <<<EOF
type {$data['function_name']}Req struct {
	Id  string `json:"id"`
	//todo 补充请求参数
}
EOF;

}else{
    $reqParams = "reqParams map[string]string";
    $function = "WithMultiQueryParam(reqParams)";
}


$code = <<<EOF
package sdk

import (
	"context"
	"fmt"
	httpclient "git.inke.cn/inkelogic/daenerys/http/client"
)

type {$data['function_name']}Response struct {
	DMErr    int    `json:"dm_error"`
	ErrorMsg string `json:"error_msg"`
	//Data map[int64][]string `json:"data"`
	//todo 补充返回参数
}

{$getReq}

/**
 * @Description: 主方法
 * @param ctx
 * @param ids
 * @return resp
 * @return err
 */
func {$data['function_name']}(ctx context.Context, {$reqParams}) (resp {$data['function_name']}Response, err error) {
	return Default.{$data['function_name']}(ctx, reqParams)
}

/**
 * @Description: http请求，调用接口
 * @param ctx
 * @param ids
 * @return resp
 * @return err
 */
func (c *Client) {$data['function_name']}(ctx context.Context, {$reqParams}) (resp {$data['function_name']}Response, err error) {
	req := httpclient.NewRequest(ctx).
		WithPath("{$data['uri']}").
		WithMethod("{$data['method']}").
		{$function}

	response, err := c.client.Call(req)
	if err != nil {
		return resp, err
	}

	if err := response.JSON(&resp); err != nil {
		return resp, err
	}

	if resp.DMErr != 0 {
		return resp, fmt.Errorf("{$data['function_name']} error: %s", resp.ErrorMsg)
	}
	return resp, nil
}
EOF;
?>
<?= $code?>
